package com.hsurosy.hsuchain.nft.base.pool;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.*;

/**
 * 线程池工具类
 *
 * @Author Hsu琛君珩
 * @Date 2024-10-04 17:32
 * @Description
 * @Version: v1.0.0
 */
public class ThreadPoolUtils {

    /**
     * 短信发送线程工厂
     */
    private static ThreadFactory smsSendFactory = new ThreadFactoryBuilder()
            .setNameFormat("demo-pool-%d").build();

    /**
     * 短信发送线程池
     */
    private static ExecutorService smsSendPool = new ThreadPoolExecutor(5, 20,
            0L, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<>(1024), smsSendFactory, new ThreadPoolExecutor.AbortPolicy());

    /**
     * 获取短信发送线程池
     *
     * @return 短信发送线程池
     */
    public static ExecutorService getSmsSendPool() {
        return smsSendPool;
    }
}
